<template>
	<div class="aid">
		<div class="base">
			<p class="fixed-top">
				{{ JSON.stringify(text) == '{}' ? '添加申请' : '修改申请' }}
				<a-icon @click="closeFunction" type="close" />
			</p>
			<div class="main" id="new_message">
				<a-form :form="form">
					<div class="zhouqiBen green" v-if="zhouqi.ApplyStartTime!=''&&zhouqi.ApplyEndTime!=''">
						{{zhouqi.Title}}：{{zhouqi.ApplyStartTime}}-{{zhouqi.ApplyEndTime}}
					</div>
					<div class="zhouqiBen red" v-else>当前暂无申请周期，无法申请</div>
					<a-form-item label="申请类型">
						<a-radio-group @change="Typechang"
							v-decorator="['Type', { rules: [{ required: true, message: '请选择申请类型' }] }]"
							name="radioGroup">
							<a-radio v-for="(item, i) in TypeData" :key="i" :value="item.Key">
								{{ item.Value }}
							</a-radio>
						</a-radio-group>
					</a-form-item>

					<!-- <a-form-item label="课程类型">
						<a-select :allowClear="true"
							v-decorator="['ActivityTypeID', { rules: [{ required: true, message: '请选择课程类型' }] }]"
							placeholder="全部" optionFilterProp="children" showSearch @change="selectChange">
							<a-select-option v-for="(item, index) in ActivityTypeData" :key="item.ID" :value="item.ID">
								{{ item.Name }}
							</a-select-option>
						</a-select>
					</a-form-item> -->
					<a-form-item label="课程类型">
						<a-tree-select :allowClear="true" show-search
							v-decorator="['ActivityTypeID', { rules: [{ required: true, message: '请选择课程类型' }] }]"
							:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
							:tree-data="ActivityTypeApplyList" tree-default-expand-all :replace-fields="replaceFields"
							placeholder="请先选择课程类型" @change="ActivityTypeApplyFun"></a-tree-select>
					</a-form-item>
					<a-form-item label="级别" v-if="Type=='1'">
						<a-select @change="changClass" :allowClear="true"
							v-decorator="['ActivityTypeScoreID', { rules: [{ required: true, message: '请选择级别' }] }]"
							placeholder="全部" optionFilterProp="children" showSearch>
							<a-select-option v-for="(item, index) in ActivityTypeScoreList" :key="item.ID"
								:value="item.ActivityLevelID">
								{{item.ActivityLevelName}}
							</a-select-option>
						</a-select>
					</a-form-item>
					<a-form-item label="类型" prop="MemberType" v-if="Type=='1'">
						<a-select v-if="zdyApplyCustomScore" v-decorator="['MemberType', { rules: [{ required: true, message: '请选择类型' }] }]"
							style="width:100%">
							<a-select-option  v-for="(item, index) in ActivityMemberTypeList" :key="item.Key"
								:value="item.Key">{{ item.Value }}
									<!-- ({{item.Key=='1'?jibieDetail.JoinScore:item.Key=='2'?jibieDetail.WorkerScore:item.Key=='3'?jibieDetail.AudienceScore:""}}分) -->
							</a-select-option>
						</a-select>
						<a-select v-else v-decorator="['MemberType', { rules: [{ required: true, message: '请选择类型' }] }]"
							style="width:100%">
							<a-select-option  v-for="(item, index) in ActivityMemberTypeList" :key="item.Key"
								:value="item.Key">{{ item.Value }}
									({{item.Key=='1'?jibieDetail.JoinScore:item.Key=='2'?jibieDetail.WorkerScore:item.Key=='3'?jibieDetail.AudienceScore:""}}分)
							</a-select-option>
						</a-select>
					</a-form-item>

					<a-form-item label="级别(获奖)" v-if="Type=='2'" prop="ActivityTypePrizeIDssss">
						<a-select @change="levalChange" style="width:100%"
							v-decorator="['ActivityTypePrizeIDssss', { rules: [{ required: true, message: '请选择级别' }] }]">
							<a-select-option v-for="(item, index) in ActivityTypePrizeTypeList" :key="item.Key"
								:value="item.ActivityLevelID">
								{{ item.ActivityLevelName }}
							</a-select-option>
						</a-select>
					</a-form-item>
					<a-form-item label="类型(获奖)" v-if="Type=='2'" prop="ActivityTypePrizeID">
						<a-select
							v-decorator="['ActivityTypePrizeID', { rules: [{ required: true, message: '请选择类型' }] }]"
							style="width:100%" @change="ActivityTypeFun">
							<a-select-option v-for="(item, index) in leaveChange" :key="item.Key" :value="item.ID">
								{{ item.Title }} {{item.ApplyCustomScore?'':'（'+item.Score+'分）'}}
								<!-- <text v-if="!item.ApplyCustomScore">({{item.Score}}分)</text> -->
							</a-select-option>
						</a-select>
					</a-form-item>
					<a-form-item label="分值" v-if="zdyApplyCustomScore">
						<a-input type="number" v-decorator="['Score', { rules: [{ required: true, message: '请输入分值' }] }]" />
					</a-form-item>
					<a-form-item :label="Type=='1'?'活动名称':'奖项名称'">
						<a-input v-decorator="['Title', { rules: [{ required: true, message: '请输入名称' }] }]" />
					</a-form-item>
					<a-form-item :label="Type=='1'?'参加时间':'获奖时间'" prop="GetTimeData">
						<a-date-picker show-time
							v-decorator="['GetTimeData',{ rules: [{ required: true, message: '请选择时间' }] }]"
							format="YYYY-MM-DD" @change="ChangData" />
					</a-form-item>
					<a-form-model-item label="佐证材料">
						<a-upload :action="requestUrl+'Common/DoUploadFile?type=file'" :file-list="icofileList"
							:default-file-list="defaultFileList" @change="e => icohandleChange(e, 'Ico')"
							:remove="(file)=>{removeFile(file, 'header')}"
							@preview="downloadFile"
							v-decorator="['Ico', { rules: [{ required: true, message: '佐证材料不能为空' }] }]">
							<div>
								<!-- <a-icon type="plus" /> -->
								<!-- <div class="ant-upload-text">Upload</div> -->
								<a-button>
									<a-icon type="upload" /> 上传
								</a-button>
							</div>
						</a-upload>
					</a-form-model-item>

					<a-form-item v-for="item in dataForm" :label="item.Name">
						<a-input v-if="item.FieldType == 1" v-decorator="[
								item.ID,
								{ rules: [{ required: item.IsMust, message: item.ErroeMsg ? item.ErroeMsg : item.Name + '不能为空' }, { validator: rules[item.ID] ? rules[item.ID].validator : '' }] }
							]" />
						<a-input v-if="item.FieldType == 2" type="textarea" :auto-size="global.textareaHeight"
							v-decorator="[
								item.ID,
								{ rules: [{ required: item.IsMust, message: item.ErroeMsg ? item.ErroeMsg : item.Name + '不能为空' }, { validator: rules[item.ID] ? rules[item.ID].validator : '' }] }
							]" />
						<a-input v-if="item.FieldType == 3" type="number" v-decorator="[
								item.ID,
								{ rules: [{ required: item.IsMust, message: item.ErroeMsg ? item.ErroeMsg : item.Name + '不能为空' }, { validator: rules[item.ID] ? rules[item.ID].validator : '' }] }
							]" />
						<a-input v-if="item.FieldType == 4" type="number" :step="0.01" v-decorator="[
								item.ID,
								{ rules: [{ required: item.IsMust, message: item.ErroeMsg ? item.ErroeMsg : item.Name + '不能为空' }, { validator: rules[item.ID] ? rules[item.ID].validator : '' }] }
							]" />
						<!-- {{ JSON.stringify(rules) }} -->
						<a-upload v-if="item.FieldType == 5 || item.FieldType == 6"
							v-decorator="[item.ID, { rules: [{ required: item.IsMust, message: item.ErroeMsg ? item.ErroeMsg : item.Name + '不能为空' }] }]"
							:accept="item.FieldType == 5 ? '.doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document' : 'image/*'"
							:multiple="true"
							:action="requestUrl+'/Common/DoUploadFile?type='+(item.FieldType == 5?'file':'image')"
							list-type="picture-card" :file-list="fileList[item.ID]" @preview="handlePreview"
							@change="e => handleChange(e, item.ID)">
							<div>
								<a-icon type="plus" />
								<div class="ant-upload-text">Upload</div>
							</div>
						</a-upload>
						<a-date-picker v-if="item.FieldType == 7" @change="e => dataChange(e, item.ID, 'data')"
							v-decorator="[item.ID, { rules: [{ required: item.IsMust, message: item.ErroeMsg ? item.ErroeMsg : item.Name + '不能为空' }] }]" />
						<a-time-picker v-if="item.FieldType == 8" @change="e => dataChange(e, item.ID, 'time')"
							v-decorator="[item.ID, { rules: [{ required: item.IsMust, message: item.ErroeMsg ? item.ErroeMsg : item.Name + '不能为空' }] }]" />
					</a-form-item>
					<a-form-item class="fixed-bottom">

						<a-popconfirm title="暂存后不会提交,在列表页点击提交按钮提交!" ok-text="好的" cancel-text="取消"
							@confirm="handleSubmit" @cancel="cancel" v-if="JSON.stringify(text) == '{}'">
							<a-button type="primary">暂存</a-button>
						</a-popconfirm>
						<a-button type="primary" v-else @click="handleSubmit">
							确认修改
						</a-button>
						<a-button style="margin-left: 10px;" @click="closeFunction">取消</a-button>
					</a-form-item>
				</a-form>
			</div>
		</div>
	</div>
</template>

<script>
	import moment from 'moment';
	import {
		UserCreditApplyDoAdd,
		UserCreditApplyTeacherDoUpdate,
		CommonDoGetActivityTypeScoreList,
		GetActivityTypePrizeListCommon,
		UserCreditApplyTeacherDoGetDetail,
		GetActivityTypeList,
		CommonDoGetActivityTypePrizeTypeList,
		DoGetActivityMemberTypeListCommon,
		CommonDoGetActivityTypePrizeList,
		UserCreditApplyDoGetFormList,
		UserCreditApplyDoGetNowSession,
		UserCreditApplyDoGetApplyActivityType,
		UserCreditApplyDoGetApplyPrizeType,
		CommonDoGetActivityTypeScoreTree,
		CommonDoGetActivityTypePrizeTree
	} from '@/api/follow';
	export default {
		props: {
			text: Object,
			// ActivityTypeData: Array,
			// ActivityTypePrizeTypeList: Array,
			// ActivityMemberTypeList: Array
		},
		watch: {
			text: function(text) {
				let that = this;
				that.icofileList = []
				if (JSON.stringify(text) == '{}') {
					that.currentID = ''
					// setTimeout(function() {
					// 	that.form.setFieldsValue({
					// 		IsTeacherExam: false,
					// 		IsAgreeUpdate: false
					// 	});
					// },300)
				} else {
					that.currentID = text.ID;
					
					let Type = '';
					if (text.ApplyType == '参加活动') {
						that.Type=1
					}
					if (text.ApplyType == '获奖') {
						that.Type=2
					}
					
					that.getOtherListList();
					that.getDetail(text.ID);
					that.ActivityTypeID=text.ActivityTypeID;
					
					 setTimeout(function() {
					
					if (text.ApplyType == '参加活动') {
						 console.log(that.pubdata);
						Type = '1'
						//级别数组赋值
						
						that.ActivityTypeScoreList=that.pubdata.filter((m, i) => m.ID == text.ActivityTypeID)[0].ScoreData;
						let ss=that.ActivityTypeScoreList.filter((m, i) => m.Data[0].ID == text.ActivityTypeScoreID)[0].ActivityLevelID;
						 that.zdyApplyCustomScore=that.ActivityTypeScoreList.filter((m, i) => m.Data[0].ID == text.ActivityTypeScoreID)[0].Data[0].ApplyCustomScore
						that.ActivityTypeScoreID=ss
						// console.log(that.ActivityTypeScoreList.filter((m, i) => m.Data[0].ID == text.ActivityTypeScoreID)[0]);
						//分数不回显示
						that.jibieDetail = that.ActivityTypeScoreList.filter((m, i) => m.ActivityLevelID == ss)[0].Data[0]
						console.log(ss);
						that.$nextTick(() => {
							setTimeout(function() {
								that.form.setFieldsValue({
									ActivityTypeScoreID: ss,
									MemberType: text.MemberType,
								});
							}, 300);
						})
					}
					
					if (text.ApplyType == '获奖') {
						Type = '2'
						that.ActivityTypePrizeTypeList=that.pubdata.filter((m, i) => m.ID == text.ActivityTypeID)[0].PrizeData;
						console.log(that.ActivityTypePrizeTypeList);
						that.zdyApplyCustomScore=that.ActivityTypePrizeTypeList.filter((m, i) => m.Data[0].ID == text.ActivityTypePrizeID)[0].Data[0].ApplyCustomScore
						let ss=''
						for(let i=0;i<that.ActivityTypePrizeTypeList.length;i++){
							for(let j=0;j<that.ActivityTypePrizeTypeList[i].Data.length;j++){
								if(text.ActivityTypePrizeID==that.ActivityTypePrizeTypeList[i].Data[j].ID){
									ss=that.ActivityTypePrizeTypeList[i].Data[j].ActivityLevelID
									that.leaveChange=that.ActivityTypePrizeTypeList[i].Data
									console.log(that.leaveChange);
								}
							}
						}
						
						that.$nextTick(() => {
							setTimeout(function() {
								that.form.setFieldsValue({
									
									ActivityTypePrizeID: text.ActivityTypePrizeID,
									ActivityTypePrizeIDssss: ss
								});
							}, 300);
						})
					}
					that.Type=Type;
					that.$nextTick(() => {
						setTimeout(function() {
							that.form.setFieldsValue({
								ActivityTypeID: text.ActivityTypeID,
								Type: Type,
								Title: text.Title,
								Score:text.Score
								// GetTimeData.[that.moment(text.GetTimeData)]
							});
						}, 300);
					})
						}, 1000);
					
				}
				
			}
		},
		data() {
			return {
				zdyApplyCustomScore:false,
				ActivityTypeApplyList2: [],
				defaultFileList: [],
				requestUrl: this.global.requestUrl,
				icofileList: [],
				fileList: {},
				replaceFields: {
					children: 'children',
					title: 'title',
					key: 'ID',
					value: 'ID'
				},
				treeselect: true,
				ActivityTypeApplyList: [],
				ActivityTypeApplyID: [],
				itemData: [],
				rules: {},
				Type: '1',
				TypeData: [{
						Key: '1',
						Value: "参加活动"
					},
					{
						Key: '2',
						Value: "获奖"
					}
				],
				ActivityTypeData: [],
				ActivityMemberTypeList: [],
				ActivityTypePrizeTypeList: [],
				// ActivityTypePrizeTypeList:[],
				GetActivityTypePrizeListCommon: [],
				ActivityTypeScoreList: [],
				dataForm: [],
				loading: false,
				formLayout: 'horizontal',
				form: this.$form.createForm(this, {
					name: 'coordinated'
				}),
				currentID: '',
				UserList: [],
				OldActivityTypeApplyList: [],
				zhouqi: {
					ApplyEndTime: "",
					ApplyStartTime: ''

				},
				jibieDetail: {},
				leaveChange: [],
				ActivityTypePrizeTypeListweiqu: [],
				pubdata: [],
			};
		},
		created() {
			this.getOtherListList();
			
			// setTimeout(function() {
			// 	this.getOtherList();
			// }, 300);
			this.$nextTick(() => {
				this.form.setFieldsValue({
					Type: '1'
				});
			})

		},
		methods: {
			ActivityTypeFun(e){
				this.zdyApplyCustomScore=this.leaveChange.filter((m, i) => m.ID == e)[0].ApplyCustomScore
			},
			
			async getOtherListList() {
				let data = {}
				data.isAgreeApply = true
				if (this.Type == '1') {
					let res = await CommonDoGetActivityTypeScoreTree(data);
					console.log(res)
					// this.ActivityTypeApplyList=res.data.newData
					// let res3 = await UserCreditApplyDoGetApplyActivityType()
					this.pubdata = res.data.newData
					this.getOtherList();
				}
				if (this.Type == '2') {
					// let res3 = await UserCreditApplyDoGetApplyPrizeType()
					// this.pubdata = res3.data.newData
					let res = await CommonDoGetActivityTypePrizeTree(data)
					console.log(res);
					this.pubdata = res.data.newData
					this.getOtherList();
				}
				let res6 = await UserCreditApplyDoGetNowSession();
				this.zhouqi = res6.data.result

			},
			ChangData(e) {
				console.log(e);
			},
			levalChange(e) {
				this.zdyApplyCustomScore=false
				if (e) {
					this.ActivityTypePrizeIDssss = e
					this.leaveChange = this.ActivityTypePrizeTypeList.filter((m, i) => m.ActivityLevelID == e)[0].Data
					console.log(this.leaveChange)
				}
				let that=this;
				if (that.Type == '2') {
					this.$nextTick(() => {
						setTimeout(function() {
							that.form.setFieldsValue({
								ActivityTypePrizeID: ''
							});
						}, 300);
					})
				}

			},
			changClass(e) {
				if (e) {
					console.log(e)
					this.ActivityTypeScoreID = e
					this.jibieDetail = this.ActivityTypeScoreList.filter((m, i) => m.ActivityLevelID == e)[0].Data[0]
					this.zdyApplyCustomScore=this.ActivityTypeScoreList.filter((m, i) => m.ActivityLevelID == e)[0].Data[0].ApplyCustomScore
					console.log(this.jibieDetail);
					console.log('ssssss+++');
					console.log(this.zdyApplyCustomScore);
				}
				let that=this;
				if (that.Type == '1') {
					this.$nextTick(() => {
						setTimeout(function() {
							that.form.setFieldsValue({
								MemberType: ''
							});
						}, 300);
					})
				}


			},
			ActivityTypeApplyFun(e) {
				
				this.zdyApplyCustomScore=false
				if (e) {
					if (this.Type == '1') {
						this.ActivityTypeID = e
						this.ActivityTypeScoreList = this.pubdata.filter((m, i) => m.ID == e)[0].ScoreData;
						console.log(this.ActivityTypeScoreList);
						if(this.ActivityTypeScoreList==undefined){
							this.$message.error('请选择该课程类型下子项课程');
						}
					}
					if (this.Type == '2') {
						this.ActivityTypeID = e
						console.log(this.ActivityTypeID+'ActivityTypeID')
						this.ActivityTypePrizeTypeList = this.pubdata.filter((m, i) => m.ID == e)[0].PrizeData;
						console.log(this.ActivityTypePrizeTypeList);
						if(this.ActivityTypeScoreList==undefined){
							this.$message.error('请选择该课程类型下子项课程');
						}
					}
				    let ParentID= this.pubdata.filter((m, i) => m.ID == e)[0].ParentID;
					let fuID=ParentID||e
					this.getformData(fuID);
				}
				let that=this;
				if (that.Type == '1') {
					this.$nextTick(() => {
						setTimeout(function() {
							that.form.setFieldsValue({
								ActivityTypeScoreID: '',
								MemberType: ''
							});
						}, 300);
					})
				}
				if (that.Type == '2') {
					this.$nextTick(() => {
						setTimeout(function() {
							that.form.setFieldsValue({
								ActivityTypePrizeIDssss: '',
								ActivityTypePrizeID: ''
							});
						}, 300);
					})
				}
			},
			Typechang(e) {
				this.Type = e.target.value;
				this.zdyApplyCustomScore=false
				this.getOtherListList();
				this.form.resetFields();
				this.icofileList=[]
				this.defaultFileList=[]
			},
			toTree(data) {
				let result = [];
				let map = {};
				if (!Array.isArray(data)) {
					return [];
				}
				data.forEach(item => {
					map[item.ID] = item;
				});
				data.forEach(item => {
					let parent = map[item.ParentID];
					if (parent) {
						(parent.children || (parent.children = [])).push(item);
					} else {
						result.push(item);
					}
				});
				return result;
			},
			cancel() {},
			async getOtherList() {
				this.ActivityTypeApplyList = this.pubdata;
				this.ActivityTypeApplyList = this.ActivityTypeApplyList.map(item => {
					return {
						...item,
						title: item.ActivityTypeName
					};
				});
				this.ActivityTypeApplyList = this.toTree(this.ActivityTypeApplyList);
				let res5 = await DoGetActivityMemberTypeListCommon();
				this.ActivityMemberTypeList = res5.data.data;

			},
			icohandleChange({
				fileList
			}, name) {
				this.icofileList = fileList;
			},
			async getformData(key) {
				let data = {};
				data.activityTypeID = key
				let res = await UserCreditApplyDoGetFormList(data)
				this.dataForm = res.data.data
			},
			async getScore(key) {
				let data = {};
				data.activityTypeID = key
				let res4 = await CommonDoGetActivityTypeScoreList(data);
				this.ActivityTypeScoreList = res4.data.data;


			},
			async getJiang(key, type) {
				let data = {};
				data.activityTypeID = key
				let res = await CommonDoGetActivityTypePrizeList(data);
				// this.ActivityTypePrizeTypeList = res.data.data
				// console.log('1111111');
				// console.log(this.ActivityTypePrizeTypeList);
				this.ActivityTypePrizeTypeListweiqu = res.data.data
				let arr = res.data.data;
				let newArr = arr.filter((currentValue, currentIndex, sourceArr) => {
					return sourceArr.findIndex(x => x.LevelID === currentValue.LevelID) === currentIndex
				});
				// console.log(newArr);
				this.ActivityTypePrizeTypeList = newArr

				if (type == 2) {
					this.leaveChange = res.data.data;
				}
			},
			selectChange(e) {
				this.getScore(e);
				this.getJiang(e);
				
			},
			async getDetail(id) {
				let data = {};
				data.id = id
				let res = await UserCreditApplyTeacherDoGetDetail(data);
				this.DetailData = res.data.data;
				this.dataForm = res.data.formData;
				let fileArr = []
				fileArr = res.data.fileData
				for (let i = 0; i < fileArr.length; i++) {
					this.icofileList.push({
						uid: i,
						name: fileArr[i].FileName,
						status: 'done',
						url: this.requestUrl + fileArr[i].FilePath,
						response: {
							fileName: fileArr[i].FileName,
							FilePath: fileArr[i].FilePath,
							url: fileArr[i].FilePath,
						}
					})
				}
				console.log(this.icofileList);

				let that = this;
				this.$nextTick(() => {
					setTimeout(function() {
						that.form.setFieldsValue({
							GetTimeData: that.moment(res.data.data.GetTime, 'YYYY-MM-DD'),
							Ico: that.icofileList
						});
					}, 300);
				})
				setTimeout(function() {
					let list = res.data.formData;
					for (var i = 0; i < list.length; i++) {
						if (list[i].FieldType == 8) {
							that.form.setFieldsValue({
								[list[i].ID]: list[i].Value.indexOf('2020-10-10') > -1 ? list[i]
									.Value : '2020-10-10 ' + list[i].Value
							});
						} else {
							that.form.setFieldsValue({
								[list[i].ID]: list[i].Value
							});
						}
						if (list[i].FieldType == 5 || list[i].FieldType == 6) {
							that.fileList = Object.assign(that.fileList, {
								[list[i].ID]: []
							});
						}
					}
					for (let i in that.fileList) {
						for (let n = 0; n < list.length; n++) {
							if (list[n].ID == i) {
								let arr = list[n].Value.split(',');
								for (let m = 0; m < arr.length; m++) {
									if (arr[m]) {
										that.fileList[i].push({
											uid: m,
											url: that.requestUrl + arr[m].split('|')[1],
											name: arr[m].split('|')[0],
											status: 'done'
										});
									}
								}
							}
						}
					}
				}, 500);
			},

			moment,
			closeFunction(data) {
				this.form.resetFields();
				this.$emit('closeFun', data);
			},
			isAssetTypeAnImage(ext) {
				return ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'psd', 'svg', 'tiff'].
				indexOf(ext.toLowerCase()) !== -1;
			},
			removeFile(file){
				console.log(file);
				console.log(this.icofileList);
				this.icofileList.forEach((value,index,array)=>{
				  if(file.name == value.name){
				    array.splice(index,1)
				  }
				})
				console.log(this.icofileList);
			},
			downloadFile(file){
				
				  let self = this;
				      const url = file.url;
					  const fileName=file.name;
				      let x = new XMLHttpRequest();
				      x.open("GET", url, true);
				      x.responseType = "blob";
				      x.onload = function() {
				        //self.exportLoading = false;
				        let url = window.URL.createObjectURL(x.response);
				        let a = document.createElement("a");
				        a.href = url;
				        a.download = fileName;
				        a.click();
				      };
				      x.send();
			},
			handleSubmit(e) {
				this.form.validateFields(async (err, values) => {
					if (!err) {
						let data = {};
						data = values;
						data.isSubmit = false;
						data.GetTime = values.GetTimeData.format('YYYY-MM-DD')
						console.log('this.ActivityTypeID'+this.ActivityTypeID)
						data.ActivityTypeID = this.ActivityTypeID;
						
						console.log(data);
						if(this.Type=='1'){
							data.ActivityTypeScoreID=this.ActivityTypeScoreList.filter((m, i) => m.ActivityLevelID == this.ActivityTypeScoreID)[0].Data[0].ID
							console.log(data);
						}
						data.fileData = [];
						console.log(this.icofileList);
						for (let i = 0; i < this.icofileList.length; i++) {
							let name = this.icofileList[i].response.fileName;
							let index = name.lastIndexOf(".");
							let ext = name.substr(index + 1);
							let type = ''
							if (this.isAssetTypeAnImage(ext)) {
								type = 1
							} else {
								type = 2
							}
							data.fileData.push({
								FileName: this.icofileList[i].response.fileName,
								FilePath: this.icofileList[i].response.url||this.icofileList[i].FilePath
							})
						}
						console.log(data.fileData);
						let res = {};
						if (!this.currentID) {
							res = await UserCreditApplyDoAdd(data);
						} else {
							data.id = this.currentID;
							res = await UserCreditApplyTeacherDoUpdate(data);
						}
						console.log(res);
						if (res.data.code === 0) {
							this.$message.success(res.data.msg);
							this.closeFunction('1');
						} else {
							this.$message.error(res.data.msg);
						}
					}
				});
			}
		}
	};
</script>

<style lang="less" scoped>
	/deep/.ant-form {
		margin-top: 50px;
		padding-bottom: 50px;
	}

	/deep/.ant-form-item {
		margin: 20px 50px;
		display: flex;
	}

	/deep/.ant-form-item-label {
		width: 100px;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		text-align: right;
	}

	/deep/.ant-form-item-control-wrapper {
		flex: 1;
	}

	/deep/.ant-calendar-picker {
		width: 100% !important;
	}

	.ant-upload-list-picture-card-container {
		width: 80px;
		height: 80px;
	}

	.zhouqiBen {
		font-size: 12px;
		padding-left: 60px;

	}

	.red {
		color: red;
	}

	.green {
		color: green;
	}
	// /deep/.anticon-delete{
	// 	display: none;
	// }
</style>
